package com.ruoyi.dispatch.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dispatch.domain.MineLevelInformation;
import com.ruoyi.dispatch.service.IMineLevelInformationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水平基本信息Controller
 * 
 * @author wuxiaofang
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/dispatch/mineLevelInfo")
@Anonymous
public class MineLevelInformationController extends BaseController
{
    @Autowired
    private IMineLevelInformationService mineLevelInformationService;

    /**
     * 查询水平基本信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:mineLevelInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(MineLevelInformation mineLevelInformation)
    {
        startPage();
        List<MineLevelInformation> list = mineLevelInformationService.selectMineLevelInformationList(mineLevelInformation);
        return getDataTable(list);
    }

    /**
     * 导出水平基本信息列表
     */
   // @PreAuthorize("@ss.hasPermi('dispatch:mineLevelInfo:export')")
    @Log(title = "水平基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MineLevelInformation mineLevelInformation)
    {
        List<MineLevelInformation> list = mineLevelInformationService.selectMineLevelInformationList(mineLevelInformation);
        ExcelUtil<MineLevelInformation> util = new ExcelUtil<MineLevelInformation>(MineLevelInformation.class);
        util.exportExcel(response, list, "水平基本信息数据");
    }

    /**
     * 获取水平基本信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:mineLevelInfo:query')")
    @GetMapping(value = "/{levelId}")
    public AjaxResult getInfo(@PathVariable("levelId") Long levelId)
    {
        return success(mineLevelInformationService.selectMineLevelInformationByLevelId(levelId));
    }

    /**
     * 新增水平基本信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:mineLevelInfo:add')")
    @Log(title = "水平基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MineLevelInformation mineLevelInformation)
    {
        mineLevelInformation.setCreateBy(getUsername());
        return toAjax(mineLevelInformationService.insertMineLevelInformation(mineLevelInformation));
    }

    /**
     * 修改水平基本信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:mineLevelInfo:edit')")
    @Log(title = "水平基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MineLevelInformation mineLevelInformation)
    {
        mineLevelInformation.setUpdateBy(getUsername());
        return toAjax(mineLevelInformationService.updateMineLevelInformation(mineLevelInformation));
    }

    /**
     * 删除水平基本信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:mineLevelInfo:remove')")
    @Log(title = "水平基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{levelIds}")
    public AjaxResult remove(@PathVariable Long[] levelIds)
    {
        return toAjax(mineLevelInformationService.deleteMineLevelInformationByLevelIds(levelIds));
    }
}
